//
//  MatchmakingServer.h
//  ProjectW
//
//  Created by Nguyen Tan Loc on 7/21/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <GameKit/GameKit.h>

typedef enum
{
    ServerStateIdle,
    ServerStateAcceptingConnections,
    ServerStateIgnoringNewConnections,
} ServerState;

@class MatchmakingServer;

@protocol MatchmakingServerDelegate <NSObject>

-(void) matchmakingServer:(MatchmakingServer*)server clientDidConnect:(NSString*)peerID;
-(void) matchmakingServer:(MatchmakingServer*)server clientDidDisconnect:(NSString*)peerID;
-(void) matchmakingServerNoNetwork:(MatchmakingServer*)server;
-(void) matchmakingServerSessionDidEnd:(MatchmakingServer*)server;

@end

@interface MatchmakingServer : NSObject <GKSessionDelegate>
{
@private 
    int _maxClients;
    GKSession *_session;
    NSMutableArray *_connectedClients;
    ServerState _serverState;
    id <MatchmakingServerDelegate> _delegate;
}

@property (nonatomic, assign) int maxClients;
@property (nonatomic, readonly) NSArray *connectedClients;
@property (nonatomic, readonly) GKSession *session;
@property (nonatomic, weak) id <MatchmakingServerDelegate> delegate;

-(void) startAcceptingConnectionForSessionID:(NSString*)sessionID;

-(int) getConnectedClientCount;
-(NSString*) getPeerIDForConnectedClientAtIndex:(int)index;
-(NSString*) getDisplayNameForPeerID:(NSString*)peerID;

@end
